package com.yl.chainStore.entity.pay

import com.baomidou.mybatisplus.annotation.IdType
import com.baomidou.mybatisplus.annotation.TableField
import com.baomidou.mybatisplus.annotation.TableId
import com.baomidou.mybatisplus.annotation.TableName
import com.yl.chainStore.common.enums.Status
import com.yl.chainStore.common.enums.TypeEnum
import com.yl.common.annotation.NoArg
import com.yl.common.getContext
import java.util.*

/**
 * <p>
 *  收款记录
 * </p>
 *
 * @author cxw
 * @since 2021-11-21
 */
@NoArg
@TableName("pay_order_customer_pay_log")
data class PayOrderCustomerPayLog(

	/**
	 * id
	 */
	@TableId(value = "id", type = IdType.AUTO)
	var id: Long,

	/**
	 * 订单id
	 */
	@TableField("order_id")
	var orderId: Long,

	@TableField(exist = false)
	var doctorName:String ?= null,

	/**
	 * 付款时间
	 */
	@TableField("create_time")
	var createTime: Date = Date(),

	/**
	 * 收款人
	 */
	@TableField("create_user_id")
	var createUserId: Long = getContext().userId,

	@TableField(exist = false)
	var createUserName:String ?= null,

	/**
	 * 公司id
	 */
	@TableField("company_id")
	var companyId: Long = getContext().companyId,

	/**
	 * 分院id
	 */
	@TableField("sub_company_id")
	var subCompanyId: Long = getContext().subCompanyId,

	@TableField(exist = false)
	var subCompanyName:String ?= null,

	/**
	 * 付款类型
	 *      普通付款
	 *      付欠费
	 */
	@TableField("pay_type")
	var payType:TypeEnum = TypeEnum.PAY_ORDER_PAY_LOG_PAY_TYPE_NORMAL,

	/**
	 * 应付金额
	 */
	@TableField("original_price")
	var originalPrice: Long = 0,

	/**
	 * 累计欠款(付款的时候)
	 */
	@TableField("the_cumulative_balance")
	var theCumulativeBalance:Long = 0,

	/**
	 * 交易状态，暂时不用
	 */
//	@TableField("pay_status")
	@TableField(exist = false)
	var payStatus:Status = Status.NORMAL,
	/**
	 * 备注
	 */
	@TableField("remark")
	var remark :String ?= null,

	/**
	 * 付款号码
	 */
	@TableField("pay_num")
	var payNum:String ?= null,


	/**
	 * 付款明细
	 */
	@TableField(exist = false)
	var details: MutableList<PayOrderCustomerPayLogDetail>? = null


){
	val payDetailShow:String
	get(){
		val payTypeBuffer = StringBuffer()
		if(details != null){
			for(detail in details!!){
				payTypeBuffer.append(""+detail.moneyShow+"("+detail.payType.typeName+") ")
			}
		}
		return payTypeBuffer.toString()
	}
}
